//
//  ViewControllerChooser.m
//  ToDo
//
//  Created by 张 霄鹤 on 10-1-27.
//  Copyright 2010 xhzhang. All rights reserved.
//

#import "ViewControllerChooser.h"

static ViewControllerChooser *chooser;

@implementation ViewControllerChooser

+ (ViewControllerChooser *)sharedChooser{
	if(chooser == nil){
		chooser = [[ViewControllerChooser alloc] init];
	}
	return chooser;
}

- (UIViewController *)choose:(NSInteger)vid{
	UIViewController *ret = nil;
	switch (vid) {
		case VC_FRIENDS_LIST:
			if(friendList == nil){
				friendList = [[TweetsViewController alloc] initWithNibName:@"TweetsViewController" bundle:nil];
			}
			ret = friendList;
			break;
		case VC_DETAIL_TWEET:
			if(detailVC == nil){
				detailVC = [[TweetDetailViewController alloc] initWithNibName:@"TweetDetailViewController" bundle:nil];
			}
			ret = detailVC;			
			break;
		case VC_REPLY_TWEET:
			if(replyVC == nil){
				replyVC = [[ReplyTweetViewController alloc] initWithNibName:@"ReplyTweetViewController" bundle:nil];
			}
			ret = replyVC;				
			break;
		case VC_ADD_ACCOUNT:
			if(addVC == nil){
				addVC = [[AddAccountViewController alloc] initWithNibName:@"AddAccountViewController" bundle:nil];
			}
			ret = addVC;
			break;
		case VC_USER_INFO:
			if(userVC == nil){
				userVC = [[UserInfoViewController alloc] initWithNibName:@"UserInfoViewController" bundle:nil];
			}
			ret = userVC;
			break;
		case VC_SEARCH_RESULT:
			if (srVC == nil) {
				srVC = [[SearchResultViewController alloc] initWithNibName:@"SearchResultViewController" bundle:nil];
			}
			ret = srVC;
			break;
		case VC_AUTH:
			if (auVC == nil) {
				auVC = [[AuthorViewController alloc] initWithNibName:@"AuthorViewController" bundle:nil];
			}
			ret = auVC;
			break;


		default:
			break;
	}
	return ret;
}

- (void)dealloc{
	if(friendList){
		[friendList release];
	}
	if(detailVC){
		[detailVC release];
	}
	if(replyVC){
		[replyVC release];
	}
	if(addVC){
		[addVC release];
	}
	if(userVC){
		[userVC release];
	}
	if (srVC) {
		[srVC release];
	}
	[auVC release];
	[super dealloc];
}

@end
